<?php
/**
 * Created by PhpStorm.
 * User: 王柯 <wangke.email@foxmail.com>
 * Date: 2018\4\28 0028
 * Time: 15:54
 */
namespace wxpay\request;
use app\common\lib\wechat\WxCommon;
class WxWithdrawalsQuery{
    /**
     * 查询提现记录
     * @param array $params 参数 *必传
     * @author 王柯 <wangke.email@foxmail.com>
     * @return array|bool|\mix|mixed|\stdClass|string
     */
    public static function exec($params){
        $wx = new WxCommon();

        //请求地址
        $url = 'https://api.mch.weixin.qq.com/mmpaysptrans/query_bank';

        //商户号
        $data['mch_id'] = config('wxpay.merchant_id');

        //查询的订单号
        $data['partner_trade_no'] = $params['order_sn'];

        //随机字符串
        $data['nonce_str'] = $wx::makeNonceStr(32);

        //签名
        $data['sign'] = $wx::makeSign($data);

        //数组转xml
        $xml = $wx::arrayToXml($data);

        //cul请求查询结果
        $result = curlRequest($url,$xml,'post',true);

        //xml转数组
        $array = $wx::xmlToArray($result);

        return $array;
    }
}